package cn.lizemin.state.version0.entity;

/**
 * @author lzm
 * @version 1.0
 * @description: TODO
 * @date 2022/4/25 10:14
 */
public class Yellow implements State {

    @Override
    public void switchToGreen(TrafficLight trafficLight) {
        System.out.println("黄灯不能切换为绿灯！");
    }

    @Override
    public void switchToYellow(TrafficLight trafficLight) {
        throw new RuntimeException("ERROR！当前状态已经是黄灯，无须再切换");
    }

    @Override
    public void switchToRed(TrafficLight trafficLight) {
        trafficLight.setState(new Red());
        System.out.println("红灯亮");

    }

}
